
<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <title>if and switch 示例</title>
</head>
<body>
    <script language="JavaScript">
     var x=1,y;
     document.write("x=1");
     document.write("<br>");
     if(x=1)
      document.write("x等于1");
     else
      document.write("x不等于1");
      document.write("<br>");
     switch(x)
     {
         case 0:document.write("x等于0");
         break;
         case 1:document.write("x是等于1");
         break;
         default:document.write("x不等于0或1")
     }

     
     //if语句,if-else语句，多重if-else(if,else if,else if,else-if,else)，switch语句
     
    </script>
</body>
</html>